package action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import entity.User;
import exception.BusinessException;
import service.UserService;
import service.imp.UserServiceImp;

public class IndexAction {
	private UserService userService = new UserServiceImp();
	private User user;
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		System.out.println("----"+user);
		this.user = user;
	}



	public String login(){
		System.out.println("action��login");
		HttpServletRequest request = ServletActionContext.getRequest();
		try {
			userService.login(user.getUsername(),user.getPassword());
			System.out.println("user.getUsername():"+user.getUsername());
		} catch (BusinessException e) {
			e.printStackTrace();
			request.setAttribute("msg", e.getMessage());
			return "error";
		} 
		
		return "success";
	}
	
	
}
